#include <iostream>
#include <vector>
using namespace std;
int main() {
  string SPR = "SPR";
  int n, m;
  cin >> m;
  string mine;
  cin >> mine;
  cin >> n;
  vector<string> players(n);
  for (auto &player : players) cin >> player;
  int ans1 = 0, ans2 = 0;

  auto judge = [](char a, char b) {
    if (a == b) return 1;
    if (a == 'S' && b == 'P') return 2;
    if (a == 'P' && b == 'R') return 2;
    if (a == 'R' && b == 'S') return 2;
    return 0;
  };

  for (int i = 0; i < m; i++) {
    vector<int> scores(3);
    for (auto &player : players) {
      ans1 += judge(mine[i], player[i]);
      for (int j = 0; j < 3; j++) {
        scores[j] += judge(SPR[j], player[i]);
      }
    }
    ans2 += max(scores[0], max(scores[1], scores[2]));
  }
  cout << ans1 << endl << ans2 << endl;
}